<?php 
include_once("DbConnection.php")

class SUCURSALES_MODEL {
	var $id;
	var $direccion;

	public function get_by_id ($_id) {
		$query = new Query("select * from SUCURSALES where id = '$_id'");
		foreach ($query->data as $obj) {
			$this->id = $obj->id;
			$this->direccion = $obj->direccion;
		}
	}

	public function get_by_direccion ($_direccion) {
		$query = new Query("select * from SUCURSALES where direccion = '$_direccion'");
		foreach ($query->data as $obj) {
			$this->id = $obj->id;
			$this->direccion = $obj->direccion;
		}
	}

	public function set_by_id ($_id) {
		$this->id = $_id;
		$query = new Query("Update SUCURSALES set 
			direccion = '$this->direccion'
			Where id == '$this->id')"
		);
	}

	public function set_by_direccion ($_direccion) {
		$this->direccion = $_direccion;
		$query = new Query("Update SUCURSALES set 
			direccion = '$this->direccion'
			Where id == '$this->id')"
		);
	}

	public function insert ( ) {
		$query = new Query("Insert into SUCURSALES (
			direccion
		) 
		values (
			'$this->direccion'
		)");
	}

	public function delete ( ) {
		$query = new Query("delete from SUCURSALES where id = '$this->id')"
		); 
	}

}
?>
